package com.zut.util;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "oss.aliyun")
public class OSSConfig {

    @Value("${spring.aliyun.oss.accessKeyId}")
    private String accessKeyId;

    @Value("${spring.aliyun.oss.accessKeySecret}")
    private String accessKeySecret;

    @Value("${spring.aliyun.oss.endpoint}")
    private String endpoint;

    @Bean
    public OSS ossClient() {

        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }
}
